package com.wedo.mall.adapter;

import android.content.Context;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.e.library.adapter.Adapter;
import com.wedo.mall.R;
import com.wedo.mall.entity.Agent;
import com.wedo.mall.util.WUrl;
import com.wedo.mall.widget.StarView;

import java.util.List;

/**
 * Created by e on 2017/8/14.
 */

public class AgentMapAdapter extends Adapter<Agent> {

    public AgentMapAdapter(Context context, List<Agent> datas) {
        super(context, datas);
    }

    @Override
    protected int layout() {
        return R.layout.item_agent_map;
    }

    @Override
    protected void bind(EHolder holder, Agent agent, int position) {

        ImageView iv_img = holder.find(R.id.iv_img);
        TextView tv_name= holder.find(R.id.tv_name);
        TextView tv_distance = holder.find(R.id.tv_distance);
        StarView sv_star = holder.find(R.id.sv_star);

        tv_name.setText(agent.agent_name);
        tv_distance.setText(String.format("%skm",agent.distance));
        sv_star.star(agent.star);
        String logo = WUrl.url(agent.logo);
        Glide.with(mContext).load(logo).error(R.drawable.place_holder_agent).placeholder(R.drawable.place_holder_agent).diskCacheStrategy(DiskCacheStrategy.ALL).into(iv_img);
    }

}
